package com.yuanfeng.commoms.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @PROJECT_NAME: mall-ms
 * @DESCRIPTION:
 * @USER: hyq
 * @DATE: 2023/2/25 20:08
 */

public class VerificationUtils {

    // 判断一个字符串是否含有数字
    public boolean hasDigit(String content) {
        boolean flag = false;
        Pattern p = Pattern.compile(".*\\d+.*");
        Matcher m = p.matcher(content);
        if (m.matches()) {
            flag = true;
        }
        return flag;
    }

    /** 判断字符串中是否包含字母 **/
    public static boolean isContainsLetter(String input){
        boolean flag = false;
        Matcher matcher = Pattern.compile(".*[a-zA-Z]+.*").matcher(input);
        if(matcher.matches()){
            flag = true;
        }
        return flag;
    }

    /**
     * 校验手机号
     **/
    public static boolean isPhonePattern(String input) {
        boolean flag = false;
        Matcher matcher = Pattern.compile("^1[0-9]{10}$").matcher(input);
        if (matcher.matches()) {
            flag = true;
        }
        return flag;
    }

    /**
     * 校验是否为纯数字
     *
     * @param str
     * @return
     */
    public static boolean isNumber(String str) {
        String reg = "^[0-9]+(.[0-9]+)?$";
        return str.matches(reg);
    }
}
